Bundle each IFP data stream with the flag and banks that govern it - #4097
Bundle each IFP data stream with the flag and banks that govern it#4097GuySten wants to merge 2 commits into
Conversation
48bb4b9 to
fd72752
Compare
fd72752 to
9d2b2dd
Compare
|
Unrelated to the refactor itself, but this branch is the right place to fix it: IFP scores can
tally.scores = ['ifp-denominator']
tally.estimator = 'analog'Separately, the multigroup whitelist in The patch rejects IFP scores in multigroup mode and validates the estimator in |
Bundle each IFP data stream with the flag and banks that govern it
Pure refactor. No behaviour change, no results change, no regolds. Follows on
from the enum removal, and is the second of the pieces split out of #3728.
Problem
IFP tracks two quantities with identical bookkeeping: the delayed group number
of the ancestor neutron (
int) and its lifetime (double). Each has a sourcebank, a fission bank, and a flag saying whether it is being maintained -- six
globals and two flags, all of which have to stay consistent with each other.
Because they are separate, every operation is written twice:
Every function in
ifp.cpphas that shape, andeigenvalue.cppcalls the MPIhelpers once per stream behind the same pair of flag checks. Nothing enforces
that a bank is only resized when its flag is set, or that the two banks of one
stream are resized together; that is a convention held up by repetition.
Changes
One type holds a stream's flag and both its banks:
Every operation is a no-op when the stream is off, so callers stop branching.
ifp()becomes:and the three
if (delayed) ...; if (lifetime) ...;pairs ineigenvalue.cppbecome unconditional calls.
deserialize_ifp_infotakes the stream rather than abank, so it can check the flag itself.
settings::ifp_delayed_onandsettings::ifp_lifetime_onare gone; the flagslive on the streams.
ifp_on()moves toifp.halongside them.free_memory_bank()previously cleared four banks by name and left the flagsalone -- the bug the previous PR fixed separately in
free_memory_settings().It is now a single
reset_ifp_streams()that clears both banks and both flags,so the two cannot drift apart again.
Effect
11 files, +219 / -252.
ifp.cppgoes from 117 lines to 53: six of its eight functions become inlinemethods and disappear.
ifp.hgrows by 56, because the class plus itsdocumentation costs more than the free functions it replaces, so the net line
count is only modestly better. The gain is structural rather than in the
diffstat: six globals and two flags become two objects, and a flag can no longer
disagree with the banks it governs.
Testing
No results change, so the existing IFP regression and unit tests cover this
unchanged. The MPI paths are exercised by the regression suite when run with
more than one process.
Notes
This makes the remaining piece of #3728 -- delaying activation of IFP tallies --
considerably smaller. That change becomes a matter of calling
enable()on thetwo streams at the right batch, rather than threading an activation condition
through
bank.cpp,eigenvalue.cpp,tally_scoring.cppandphysics.cpp.Checklist
I have followed the style guidelines for Python source files (if applicable)I have made corresponding changes to the documentation (if applicable)I have added tests that prove my fix is effective or that my feature works (if applicable)